package org.Multibot;
import org.Multibot.Configuration;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
import org.Multibot.Gui.botGUI;
import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.theme.SubstanceEbonyTheme;
import org.jvnet.substance.title.FlatTitlePainter;

public class Application extends JFrame {

    private static botGUI gui;
	public static boolean setTheme() {
        try {
            UIManager.setLookAndFeel(new SubstanceLookAndFeel());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
            SubstanceLookAndFeel.setCurrentTheme(new SubstanceEbonyTheme());
            SubstanceLookAndFeel.setCurrentTitlePainter(new FlatTitlePainter());
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
	public Application() {
		try {
			initComponents();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String[] language = {"English","German"};
	private void initComponents() {
		final JFrame frame = new JFrame("Multibot - Select Language");
		JScrollPane pane = new JScrollPane();
		JPanel panel = new JPanel();
		final JList list = new JList(language);
        final JButton button = new JButton("Select");  
		button.setPreferredSize(new Dimension(265, 20));
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		list.setVisibleRowCount(2);
		button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
				int idx = list.getSelectedIndex();
				if (idx == 0) {
					button.setEnabled(false);
					new botGUI().setVisible(true);
					frame.setVisible(false);
				}
				if (idx == 1) {
					Configuration.LANGUAGE = "l=1/";
					new botGUI().setVisible(true);
					frame.setVisible(false);
					button.setEnabled(false);
				}
            }
		});

		pane.setViewportView(list);
		panel.add(pane);
		panel.add(button);
		list.setPreferredSize(new Dimension(250, 50));
		frame.setPreferredSize(new Dimension(275, 100));
		frame.add(panel);
		frame.pack();
		frame.setResizable(false);
		frame.setVisible(true);
		frame.setLocationRelativeTo(getRootPane());
	}
	public static Dimension getPanelSize() {
        return gui.getPanel().getSize();
    }
	@SuppressWarnings("unused")
	public static void main(String[] args) {
		try {
			setTheme();
			new Application().setVisible(false);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
